package interfaces.inputValidation;

import fileHandling.language.LanguageLoader;
import fileHandling.language.interfaces.Validation;

public class IPInputChecker implements InputChecker {
	
	protected IntegerBoundsChecker boundsChecker;
	
	public IPInputChecker() {
		boundsChecker = new IntegerBoundsChecker(0, 255);
	}
	
	@Override
	public boolean isValid(String input) {
		String[] parts = input.split("[.]");
		if(parts.length != 4) return false;
		
		for(String part : parts) {
			if(!boundsChecker.isValid(part)) return false;
		}
		return true;
	}
	
	@Override
	public String getDescription() {
		return LanguageLoader.get(Validation.NoValidIP);
	}
}